﻿using SimpleServiceBus.Bus.MessageManagement.MessageHandling;

namespace SimpleServiceBus.Bus.Pipeline.PipelineComponents
{
    public class MessageHandlerDispatcherComponent : PipelineComponentBase
    {
        public MessageHandlerDispatcherComponent():base("MessageHandlerDispatcher")
        {
        }

        protected override void ProcessMessage(MessageEnvelope messageEnvelope, IMessageContext context)
        {
            var svc = context.GetLocalService<IMessageDispatcher>();
            if (svc != null)
                svc.Dispatch(messageEnvelope, context);
        }
    }
}